package com.regan.erp.service;

import cn.hutool.core.lang.Dict;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.SqlPara;
import com.regan.erp.model.Role;
import com.regan.erp.util.FunctionUtils;

/**
 * 角色服务
 *
 * @author zhangby
 * @date 2018/10/17 下午2:14
 */
public class RoleService {

    /**
     * 获取角色列表数据
     *
     * @param paramDict
     * @return
     * @author zhangby
     * @date 2018/10/17 下午2:17
     */
    public Page<Role> getRoleListData(Dict paramDict) {
        SqlPara sqlPara = Db.getSqlPara("role.getRoleListData", paramDict);
        Page<Role> paginate = Role.dao.paginate(paramDict.getInt("pageNum"), paramDict.getInt("pageSize"), sqlPara);
        FunctionUtils.execute(paginate.getList(),role->{
            role.setMenuIds(role.get("menuIds"));
            role.setHalfMenuIds(role.get("halfMenuIds"));
        });
        return paginate;
    }
}
